﻿package org.leles.aom.events 
{
	import com.adobe.serialization.json.JSON;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author Bruno Leles
	 */
	public class ChannelEvent extends ActivityBaseEvent 
	{
		public static const APP_CLOSE:String			= "APP_CLOSE";
		public static const DATA_ERROR:String			= "DATA_ERROR";
		public static const DATA_RECEIVED:String		= "DATA_RECEIVED";
		public static const FILE_PROGRESS:String		= "FILE_PROGRESS";
		public static const FILE_RECEIVED:String		= "FILE_RECEIVED";
		public static const IM_RECEIVED:String			= "IM_RECEIVED";
		public static const REMOTE_APP_CLOSED:String	= "REMOTE_APP_CLOSED";
		public static const REMOTE_APP_LOADED:String	= "REMOTE_APP_LOADED";
		public static const SENDFILE_CANCELLED:String	= "SENDFILE_CANCELLED";
		public static const TYPE_CHANGED:String			= "TYPE_CHANGED";
		
		public var data:*;
		
		public function ChannelEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) 
		{ 
			super(type, bubbles, cancelable);
		} 
		
		public override function clone():Event 
		{ 
			var ev:ChannelEvent = new ChannelEvent(type, bubbles, cancelable);
			ev.data = this.data;
			return  ev;
		} 
		
		public override function toString():String 
		{ 
			return formatToString("ChannelEvent", "type", "bubbles", "cancelable", "eventPhase", "data"); 
		}
		
		public override function loadEventData(eventData:*):void 
		{
			super.loadEventData(eventData);
			this.data = JSON.decode( eventData.data );
		}
		
	}
	
}